package com.gm.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig {

    @Bean
    public WebMvcConfigurer webMvcConfigurer(){
        WebMvcConfigurer webMvcConfigurer = new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
//                registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**")
//                        .excludePathPatterns("/login.html","/","/user/login")
//                        .excludePathPatterns("/asserts/**")
//                        .excludePathPatterns("/webjars/**");
            }

            @Override
            public void addViewControllers(ViewControllerRegistry registry) {
                registry.addViewController("/").setViewName("login");
                registry.addViewController("/login.html").setViewName("login");
                registry.addViewController("/main.html").setViewName("index");
                //Admin
                registry.addViewController("/admin-list.html").setViewName("admin-list");
                registry.addViewController("/adminAdd.html").setViewName("admin-add");
                registry.addViewController("/adminUpd.html").setViewName("admin-upd");
                //Book
                registry.addViewController("/book-list.html").setViewName("book-list");
                registry.addViewController("/bookAdd.html").setViewName("book-add");
                registry.addViewController("/bookUpd.html").setViewName("book-upd");
                //user
                registry.addViewController("/user-list.html").setViewName("user-list");
//                registry.addViewController("/bookAdd.html").setViewName("book-add");
//                registry.addViewController("/bookUpd.html").setViewName("book-upd");

            }

        };
        return webMvcConfigurer;
    }

//    @Bean
//    public LocaleResolver localeResolver(){
//        return new MyLocaleResolver();
//    }

}
